﻿using Abp.CustomConsoleModule;
using Abp.MyPluginsInterfaceModule;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Abp.ConsoleModule
{
    /// <summary>
    /// 
    /// </summary>
    internal class AbpConsoleHostService : IHostedService
    {

        /// <summary>
        /// 自定义插件模块-(使用接口间接使用，继承自AbpModule模块的插件模块通过ConfigureServices调用)
        /// </summary>
        public IMyOssInterface myOssInterface { get; set; }
        /// <summary>
        /// 使用属性注入HelloWorldService
        /// </summary>
        public HelloWorldService helloWorldService { get; set; }
        /// <summary>
        /// 属性注入方式使用自定义文件上传模块
        /// </summary>
        public MyFileUploadService myFileUploadService { get; set; }

        
        public Task StartAsync(CancellationToken cancellationToken)
        {
            //直接调用
            helloWorldService.Show();
            helloWorldService.OnStart();

            //使用Abp模块注入后调用
            myFileUploadService.FileUpload();

            //使用自定义插件上传模块(热插拔方式,加载实现模块的dll文件即可)
            myOssInterface.UploadFile();

            return Task.CompletedTask;
        }

        public Task StopAsync(CancellationToken cancellationToken) { 
            
            helloWorldService.OnStop();
            return Task.CompletedTask;

        }



    }
}
